import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class ComboxColor(QWidget):
    def __init__(self, parents=None):
        super(ComboxColor, self).__init__(parents)
        self.setWindowTitle('ComboxColor')
        self.resize(300, 90)
        layout = QVBoxLayout()
        self.lbl = QLabel('red')

        self.cb = QComboBox()
        self.cb.addItem('red')
        self.cb.addItems(['blue', 'green', 'yellow'])
        self.cb.currentIndexChanged.connect(self.schange_color)
        layout.addWidget(self.cb)
        layout.addWidget(self.lbl)
        self.selected_color='red'
        self.setLayout(layout)

    def schange_color(self, i):
        self.lbl.setText(self.cb.currentText())
        self.selected_color=self.cb.currentText()
        # print('Items are:')
        # for count in range(self.cb.count()):
        #     print('item' + str(count) + '=' + self.cb.itemText(count))
        #     print('Current index', i, 'changed', self.cb.currentText())
    def __del__(self):
        print(self.selected_color)
        return self.selected_color

if __name__ == '__main__':
    app = QApplication(sys.argv)
    combox = ComboxColor()
    combox.show()
    sys.exit(app.exec_())
